#!/usr/bin/env python
# Create: 2018/8/8
__author__ = '749B'

from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout


def acc_login(request):
    if request.method == 'POST':
        acc = {
            'username': request.POST.get('username'),
            'password': request.POST.get('password'),
        }
        user = authenticate(request, **acc)
        if user:
            login(request, user)
            next = request.GET.get('next') or '/crm/'
            return redirect(next)
    return render(request, 'signin.html')


def acc_logout(request):
    logout(request)
    return redirect('/login/')




